#include "message.h"


message::message() {
    mgsMAX = 13;
}


void message::Init(void) {
    int i;
    for(i=0;i<=mgsMAX;i++) Message[i].Text = " ";

    cntMessage = 0;
    MessagePos = 0;

    Add("Message System gestartet");
}


void message::Draw(void) {
    int i;
    attrset(A_NORMAL | COLOR_PAIR(3));
    for(i = 0; i <= mgsMAX; i++ ) mvprintw(i,40,Message[i].Text.c_str());
    move(LINES-1,1);
}


void message::Add(string pText) {
    int i;
    if(MessagePos <= mgsMAX) { // Noch Platz
        Message[MessagePos].Text = pText;
        MessagePos++;
    } else {                  // Schieben
        cntMessage=0;
        for(i=0;i<mgsMAX;i++)  Message[i] = Message[i+1];
        Message[mgsMAX].Text = pText;
    }
}


void message::Tick(void) {
    cntMessage++;
    int i;
    if(cntMessage>=20) { // X Sekunden
        cntMessage = 0;
        for(i=0;i<mgsMAX-1;i++)  Message[i] = Message[i+1];
        Message[mgsMAX].Text = " ";
        if(MessagePos > 0)MessagePos--;
    }
}


void message::Destroy(void) {



}




